#include<func.h>
int main (int argc,char *argv[])
{
    ARGS_CHECK(argc,2);
   int fdr = open(argv[1],O_RDWR);
   int fdw = open(argv[1],O_RDWR);
   puts("pipe open");
  char buf[4096]={0};
  int ret;
  fd_set rdset;
  fd_set wdset; 
  int cnt;
  while(1)
{
    FD_ZERO(&rdset);
   
    FD_SET(fdr,&rdset); 
    FD_ZERO(&wdset);
    FD_SET(fdw,&wdset);
    select(fdw+1,&rdset,&wdset,NULL,NULL);
   
    if(FD_ISSET(fdr,&rdset))
    {
     memset(buf,0,sizeof(buf));
     printf("r= %d\n",cnt++);
     read(fdr,buf,sizeof(buf));
   
    }

    if(FD_ISSET(fdw,&wdset))
    {
    memset(buf,0,sizeof(buf));
     printf("w= %d\n",cnt++);
write(fdw,buf,strlen(buf)+1);
     
    }
    sleep(1);
}
}